package com.fairytask.ui.item
{
	import com.fairytask.engine.components.clip.Clip;
	import com.fairytask.engine.components.text.Label;
	import com.fairytask.engine.components.text.Text;
	import com.fairytask.engine.define.ResConfig;
	import com.fairytask.managers.ResManager;
	import com.fairytask.managers.TipsManage;
	import com.fairytask.resource.StaticIni;
	import com.fairytask.tools.GoodSet;
	import com.fairytask.tools.TipsTools;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	/**
	 * 任务UI任务奖励物品项
	 * @author zhuy
	 * 
	 */	
	public class TaskAwardItem extends Sprite
	{
		private var _bg		: MovieClip;//框
		private var _clip		: Clip;		//图标
		private var _nameTxt 	: Text;		//名称
		private var _numLab	: Label;	//数量
		
		private var _configID	: int;
		public function TaskAwardItem(configID:int,num:int=0)
		{
			_configID = configID;
			
			_bg = ResManager.newResClass("CustSkin_017") as MovieClip;
			_bg.width = 56;
			_bg.height= 56;
			addChild(_bg);
			
			_clip = new Clip(false,null,"jzLogo");
			var str :String		=	StaticIni.getIniVar(_configID, "Icon");
			var str1:String		=	ResConfig.iconPath + str + ResConfig.iconImg;
			_clip.source = str1; 
			_clip.x = 2.5;
			_clip.y = 2;
			addChild(_clip);
			
			if(num!=0)
			{
				_numLab = new Label();
				GoodSet.setNumPos(_numLab,num);
				addChild(_numLab);
			}
			
			_nameTxt = new Text(80,40,"vScrol_1","vScrol_4");
			_nameTxt.setFilter();
			_nameTxt.htmlStr = TipsTools.link_color(StaticIni.getSwfLangStr(StaticIni.getIniVar(_configID, "NameID")),int(StaticIni.getIniVar(_configID, "Color")));
			_nameTxt.x = 39;
			_nameTxt.y = 2;
			//addChild(_nameTxt);
			initEvent();
		}
		
		private function initEvent():void
		{
			addEventListener(MouseEvent.ROLL_OVER,onOver);
			addEventListener(MouseEvent.ROLL_OUT,onOut);
		}
		
		private function onOver(evt:MouseEvent):void
		{
			TipsManage.ShowAllItemsTips(int(StaticIni.getIniVar(_configID,"ItemType")),_configID);
		}
		
		private function onOut(evt:MouseEvent):void
		{
			TipsManage.hideTips();
		}
		
		public function clear():void
		{
			_bg = null;
			_clip.clear();
			_clip = null;
			_nameTxt.clear();
			_nameTxt = null;
			_numLab = null;
			removeEventListener(MouseEvent.ROLL_OVER,onOver);
			removeEventListener(MouseEvent.ROLL_OUT,onOut);
		}
	}
}